/*
 * Copyright (C) by Fluid Operations.
 * All rights reserved.
 *
 * For more information go to http://www.fluidops.com
 */

package com.fluidops.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;

import com.fluidops.util.help.Topic;
import com.fluidops.util.help.eclipsehelp.EclipseHelpContent;
import com.fluidops.util.help.javahelp.JavaHelpContent;

/**
 * @author stefan
 *
 */
public class Jh2Eh
{
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception
	{
		if(args == null || args.length < 7)
		{
			System.out.println("USAGE: Jh2Eh <Java Help cfg.> <dest path> <product name> <product ID> <plugin name> <plugin ID> <plugin version>");
			System.out.println("where 'plugin name', 'plugin ID' and 'plugin version' define the idendity of the Eclipse plugin while 'product name' and 'product ID' define the idendity of the help contained in the plugin");
			return;
		}
		
		String sourceConfig = args[0];
		String destConfig = args[1];

		System.out.println("Parsing Java Help configuration...");
		JavaHelpContent conf = new JavaHelpContent();
		conf.parse(sourceConfig);
		
		System.out.println("Transforming to Eclipse Help...");
		EclipseHelpContent dest = new EclipseHelpContent(conf);
		dest.primary = true;
		
		// get the info for the help product definition
		// note: A plugin can contain several products. However, in this case we only define one product, the help!
		dest.productName = args[2];
		dest.productID = args[3];
		
		// get the plugin information required to create a valid plugin structure
		dest.pluginName = args[4];
		dest.pluginID = args[5];
		dest.pluginVersion = args[6];

		System.out.println("Writing Eclipse help...");
		dest.write(destConfig);
		System.out.println("Success!");
	}

}
